$(document).ready(function(){
	var monthToPlotOnChart    = $("#monthToPlotOnChart").val();
	monthToPlotOnChart = monthToPlotOnChart.replace("[","");
	monthToPlotOnChart = monthToPlotOnChart.replace("]","");
	monthToPlotOnChart = monthToPlotOnChart.trim();
	
	var initialDate = $("#initialDateToShow").val();
	var endDate = $("#endDateToShow").val();
	
	var daysValuesToPlotOnChart = $("#daysValuesToPlotOnChart").val();
	var monthToPlotOnChartArr  = monthToPlotOnChart.split(',');
	
	var daysValuesToPlotOnChartJSON = JSON.parse(daysValuesToPlotOnChart)
	
        $('#container').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: 'Previsão de pagamentos a receber de '+initialDate+' a '+ endDate
            },
           
            xAxis: {
                categories: monthToPlotOnChartArr,
                title: {
                    text: 'Meses'
                }
            },
            yAxis: {
                min: 0,
                title: {
                    text: 'Valores em R$'
                },
            },
            tooltip: {
                headerFormat: '<span style="font-size:9px">EM -{point.key}</span><table>',
                pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                    '<td style="padding:0"><b>{point.y:.2f}</b></td></tr>',
                footerFormat: '</table>',
                shared: true,
                useHTML: true
            },
            plotOptions: {
                column: {
                    pointPadding: 0.1,
                    borderWidth: 0,
                    dataLabels: {
                        enabled: true,
                        format: '{point.y}'
                    }
                }
            },
            
            series: []
        });
	
	var chart = $('#container').highcharts();
	for (var key in daysValuesToPlotOnChartJSON) {
	  if (daysValuesToPlotOnChartJSON.hasOwnProperty(key)) {
		var dataParsed = daysValuesToPlotOnChartJSON[key];
		for(var i = 0;i < dataParsed.length;i++){
			dataParsed[i] = Number.parseFloat(dataParsed[i]);
		}
		var series = chart.addSeries({
		    name: key,
		    data: dataParsed
		 });
	  }
	}
});